<?php
/*
Form to submit a calendar feed or moderation.
*/

$title = "Submit a Calendar";
include('includes/header.php');

/* Process the post data */
if ($_POST) {
	if (strlen($_POST['name']) && strlen($_POST['short_name']) && strlen($_POST['url'])) {

		$data = array(
				"name"=>$_POST['name'],
				"short_name"=>$_POST['short_name'],
				"url"=>$_POST['url'],
				"approved"=>0
		);
		$result = mysql_insert("feeds",$data);
		notify_pending();
		if ($result) echo "<div class='good-news'>Calendar Submitted for Moderation.</div>";
	} else {
		echo "<div class='bad-news'>All fields are required.</div>";
	}
}
?>

<p>
Want your organization's calendar included in the Colonial Calendar?  Simply submit the iCal feed URL below and events will automatically be added.
</p>
<form method='post'>
	<div class='form-row'>
		<div class='form-label'>
			<label for='name'>
				Name
			</label>
			<div class='desc'>
			Example: College Democrats, College Repbulicans, GW Hillel
			</div>
		</div>
		<div class='form-field'>
			<input type='text' name='name' id='name' size='30' value='<?php echo $_POST['name']; ?>'/>
		</div>
	</div>
	<div class='form-row'>
		<div class='form-label'>
			<label for='short_name'>
				Short Name
			</label>
			<div class='desc'>
			Example: CDs, CRs, Hillel
			</div>
		</div>
		<div class='form-field'>
			<input type='text' name='short_name' id='short_name' size='30' value='<?php echo $_POST['short_name']; ?>'/>
		</div>
	</div>
	<div class='form-row'>
		<div class='form-label'>
			<label for='url'>
				Feed URL
			</label>
			<div class='desc'>
			Example: http://<br />gwstudentassociation.com/ <br />calendar/subscribe/
			</div>
		</div>
		<div class='form-field'>
			<input type='text' name='url' id='url' <?php if ($_POST['url']) { ?> value='<?php echo $_POST['url']; ?>' <?php } else { ?> value='http://' <?php } ?> size='30'/>
		</div>
	</div>
	<div class='form-row'>
		<div class='form-label'>
		</div>
		<div class='form-field'>
			<input type='submit' value='Submit' />
		</div>
	</div>
</form>
<?php include('includes/footer.php'); ?>

